package com.sightp.tujubeacon.fragments.map;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.palmaplus.nagrand.data.LocationModel;
import com.palmaplus.nagrand.easyapi.Map;
import com.palmaplus.nagrand.view.MapView;
import com.sightp.tujubeacon.R;
import com.sightp.tujubeacon.fragments.base.BaseFragment;
import com.sightp.tujubeacon.utils.Constants;

/**
 * Created by Xu XiaoYang on 2017/7/26.
 */

public class BaseMapFragment extends BaseFragment {

    protected MapView mapVIew;

    @Override
    public View provideView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_base_map, container, false);
    }

    @Override
    public void onInitFragment(Bundle savedInstanceState) {
        super.onInitFragment(savedInstanceState);
        //获取MapView
        mapVIew = (MapView) view.findViewById(R.id.mapView);
        // 通过MapView获取Map对象，并且根据MapID渲染地图
        mapVIew.getMap().startWithMapID(Constants.mapId);

/*
// 移动地图到对应的Feature对象到地图中心，1000为动画持续的时间，单位为毫秒
        Map map = mapVIew.getMap();
        map.mapView().moveToFeature(feature, true, 1000);
        Toast.makeText(
                getContext(),
                String.format("%s -- %s -- %s", LocationModel.id.get(item) + "", LocationModel.display.get(item), LocationModel.address.get(item) == null ? "" : LocationModel.address.get(item)),
                Toast.LENGTH_LONG
        ).show();
*/

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        //销毁地图
        mapVIew.drop();
    }
}
